﻿using BTerrariaMod.Bards;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using Terraria;

namespace BTerrariaMod.Tests
{
    
    
    /// <summary>
    ///This is a test class for ChestBardTest and is intended
    ///to contain all ChestBardTest Unit Tests
    ///</summary>
    [TestClass()]
    public class ChestBardTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///A test for ChestOpened
        ///</summary>
        [TestMethod()]
        public void ChestOpenedTest()
        {
            ChestBard target = new ChestBard(Console.WriteLine);
            Player activePlayer = new Player() {chest = 0}; 
            Chest openedChest = new Chest(){ item=new Item[]{}}; 
            target.ChestOpened(activePlayer, openedChest);
            
        }

        /// <summary>
        ///A test for AnnounceChestItems
        ///</summary>
        [TestMethod()]
        public void AnnounceChestItemsTest()
        {
            ChestBard_Accessor target = new ChestBard_Accessor(Console.WriteLine);
            Player activePlayer = new Player(); 
            Chest freshChest = new Chest(); 
            Item i = new Item(); 
            target.AnnounceChestItems(activePlayer, freshChest, i);
            
        }

        /// <summary>
        ///A test for ChestBard Constructor
        ///</summary>
        [TestMethod()]
        public void ChestBardConstructorTest()
        {
            ChestBard target = new ChestBard(Console.WriteLine);
            
        }

        /// <summary>
        ///A test for UpdateChestCache
        ///</summary>
        [TestMethod()]
        public void UpdateChestCacheTest()
        {
            ChestBard_Accessor target = new ChestBard_Accessor(Console.WriteLine); // TODO: Initialize to an appropriate value
            int chestID = 0; // TODO: Initialize to an appropriate value
            Chest chest = null; // TODO: Initialize to an appropriate value
            target.UpdateChestCache(chestID, chest);
        }

        /// <summary>
        ///A test for isChestLootOfInterest
        ///</summary>
        [TestMethod()]
        public void isChestLootOfInterestTest()
        {
            ChestBard_Accessor target = new ChestBard_Accessor(Console.WriteLine);
            Item i = new Item(){ name="testitem", value=0}; 
            bool expected = false;
            bool actual = target.IsChestLootOfInterest(i);
            Assert.AreEqual(expected, actual);
            
        }

        /// <summary>
        ///A test for isChestLootOfInterest
        ///</summary>
        [TestMethod()]
        public void isChestLootOfInterest_ValueOverThreshold_ReturnsTrue()
        {
            ChestBard_Accessor target = new ChestBard_Accessor(Console.WriteLine);
            Item i = new Item() { name = "testitem", value = ChestBard.DefaultValueThreshold+1 };
            bool expected = true;
            bool actual = target.IsChestLootOfInterest(i);
            Assert.AreEqual(expected, actual);

        }
        /// <summary>
        ///A test for isChestLootOfInterest
        ///</summary>
        [TestMethod()]
        public void isChestLootOfInterest_null_ReturnsFalse()
        {
            ChestBard_Accessor target = new ChestBard_Accessor(Console.WriteLine);
            Item i =null;
            bool expected = false;
            bool actual = target.IsChestLootOfInterest(i);
            Assert.AreEqual(expected, actual);

        }

        /// <summary>
        ///A test for isChestLootOfInterest
        ///</summary>
        [TestMethod()]
        public void isChestLootOfInterest_EmptyName_ReturnsFalse()
        {
            ChestBard_Accessor target = new ChestBard_Accessor(Console.WriteLine);
            Item i = new Item() { name=string.Empty};
            bool expected = false;
            bool actual = target.IsChestLootOfInterest(i);
            Assert.AreEqual(expected, actual);

        }

        /// <summary>
        ///A test for isChestLootOfInterest
        ///</summary>
        [TestMethod()]
        public void isChestLootOfInterest_ValueAtThreshold_ReturnsFalse()
        {
            bool expected = false;

            ChestBard_Accessor target = new ChestBard_Accessor(Console.WriteLine);
            Item i = new Item() { name = "testitem", value = ChestBard.DefaultValueThreshold };
            

            bool actual = target.IsChestLootOfInterest(i);

            Assert.AreEqual(expected, actual);

        }

    }
}
